From: Руслан Ижбулатов Date: Sun, 26 Nov 2017 00:21:22 +0000 (+0000) Subject: GDK W32: Preserve the target value for change_property() X-Git-Tag: archive/raspbian/3.24.39-1+rpi1~1^2~65^2~38^2~142 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success/%22http:/www.example.com/cgi/success?a=commitdiff_plain;h=56074fbf3c3bdf760b444c7196c9c4aac659eeee;p=gtk%2B3.0.git GDK W32: Preserve the target value for change_property() We need to know the target atom value to know when we need to do something with side-effects (since side-effects are expressed via special target values). Previously, the code side-stepped that by looking at the data type (which was rather unique for the one side-effect target that we supported, signalled by the TARGETS target), but for the DELETE target that seems to be no longer an option, hence the new field to carry this information past the convert_selection() routine. This prevents GDK from throwing a warning when trying to convert a DELETE target, which has no format or data objects set. The side-effects for the DELETE target happen earlier, in GTK layer. By the point it gets to change_property(), it's a no-op. https://bugzilla.gnome.org/show_bug.cgi?id=786509 --- diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c index fc4dfb0de0..cb7eaa5c37 100644 --- a/gdk/win32/gdkdnd-win32.c +++ b/gdk/win32/gdkdnd-win32.c @@ -1057,6 +1057,7 @@ idataobject_getdata (LPDATAOBJECT This, { target = frec->target; win32_sel->property_change_transmute = frec->transmute; + win32_sel->property_change_target_atom = frec->target; } } @@ -2130,6 +2131,7 @@ _gdk_win32_dnd_do_dragdrop (void) /* Delete dnd selection after successful move */ if (hr == DRAGDROP_S_DROP && dwEffect == DROPEFFECT_MOVE) { + GdkWin32Selection *win32_sel = _gdk_win32_selection_get (); GdkEvent tmp_event; memset (&tmp_event, 0, sizeof (tmp_event)); @@ -2138,6 +2140,7 @@ _gdk_win32_dnd_do_dragdrop (void) tmp_event.selection.send_event = FALSE; tmp_event.selection.selection = _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_OLE2_DND); tmp_event.selection.target = _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_DELETE); + win32_sel->property_change_target_atom = _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_DELETE); tmp_event.selection.property = _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_OLE2_DND); g_set_object (&tmp_event.selection.requestor, drag_ctx->source_window); tmp_event.selection.time = GDK_CURRENT_TIME; /* ??? */ diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index 873d225227..a2cd67cf03 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -3815,6 +3815,7 @@ gdk_event_translate (MSG *msg, property_change_data = g_new0 (STGMEDIUM, 1); win32_sel->property_change_data = property_change_data; win32_sel->property_change_format = msg->wParam; + win32_sel->property_change_target_atom = target; fixup_event (event); GDK_NOTE (EVENTS, g_print (" (calling _gdk_event_emit)")); diff --git a/gdk/win32/gdkselection-win32.c b/gdk/win32/gdkselection-win32.c index 5fd02a698e..ce42d0d12d 100644 --- a/gdk/win32/gdkselection-win32.c +++ b/gdk/win32/gdkselection-win32.c @@ -357,6 +357,7 @@ gdk_win32_selection_init (GdkWin32Selection *win32_selection) win32_selection->dnd_data_object_target = NULL; win32_selection->property_change_format = 0; win32_selection->property_change_data = NULL; + win32_selection->property_change_target_atom = 0; atoms = g_array_sized_new (FALSE, TRUE, sizeof (GdkAtom), GDK_WIN32_ATOM_INDEX_LAST); g_array_set_size (atoms, GDK_WIN32_ATOM_INDEX_LAST); @@ -894,6 +895,7 @@ send_targets_request (guint time) tmp_event.selection.property = _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_GDK_SELECTION); tmp_event.selection.requestor = owner; tmp_event.selection.time = time; + win32_sel->property_change_target_atom = _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_TARGETS); gdk_event_put (&tmp_event); win32_sel->targets_request_pending = TRUE; @@ -2325,8 +2327,10 @@ _gdk_win32_selection_property_change (GdkWin32Selection *win32_sel, gint nelements) { if (property == _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_GDK_SELECTION) && - type == GDK_SELECTION_TYPE_ATOM) /* implies target == _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_TARGETS) */ + win32_sel->property_change_target_atom == _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_TARGETS)) { + win32_sel->property_change_target_atom = 0; + if (win32_sel->clipboard_opened_for == INVALID_HANDLE_VALUE && OpenClipboard (GDK_WINDOW_HWND (window))) { @@ -2345,11 +2349,22 @@ _gdk_win32_selection_property_change (GdkWin32Selection *win32_sel, open_clipboard_timeout (NULL); } } + else if (property == _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_OLE2_DND) && + mode == GDK_PROP_MODE_REPLACE && + win32_sel->property_change_target_atom == _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_DELETE)) + { + /* no-op on Windows */ + win32_sel->property_change_target_atom = 0; + } else if (mode == GDK_PROP_MODE_REPLACE && - (win32_sel->property_change_data == NULL || + (win32_sel->property_change_target_atom == 0 || + win32_sel->property_change_data == NULL || win32_sel->property_change_format == 0)) { - g_warning ("Setting selection property with 0x%p == NULL or 0x%x == 0", win32_sel->property_change_data, win32_sel->property_change_format); + g_warning ("Setting selection property with 0x%p == NULL or 0x%x == 0 or 0x%p == 0", + win32_sel->property_change_data, + win32_sel->property_change_format, + win32_sel->property_change_target_atom); } else if (mode == GDK_PROP_MODE_REPLACE && win32_sel->property_change_data != NULL && @@ -2396,6 +2411,7 @@ _gdk_win32_selection_property_change (GdkWin32Selection *win32_sel, win32_sel->property_change_format = 0; win32_sel->property_change_data = 0; + win32_sel->property_change_target_atom = 0; } else { diff --git a/gdk/win32/gdkselection-win32.h b/gdk/win32/gdkselection-win32.h index ed65087244..c3ed6cd45e 100644 --- a/gdk/win32/gdkselection-win32.h +++ b/gdk/win32/gdkselection-win32.h @@ -167,6 +167,8 @@ struct _GdkWin32Selection LPSTGMEDIUM property_change_data; /* Carries the transmute field of the GdkSelTargetFormat from from idataobject_getdata() to property_change() */ gboolean property_change_transmute; + /* Carries the target atom from GDK_SELECTION_REQUEST issuer to property_change() */ + GdkAtom property_change_target_atom; /* TRUE when we are emptying the clipboard ourselves */ gboolean ignore_destroy_clipboard;